<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@include file="../public/header.jsp" %>

<img src="<%=request.getContextPath()+"/resources/images/userprofile_logo.jpg"%>" class="logo">

<div class="form-wrapper userprofile-form-wrapper"> 
	<div class="form-header">
		<div class="form-title">
			<fmt:message key="label.userprofile.title"></fmt:message>
		</div> 
	</div>
	<div class="form-body">
		<form:form id="userProfileFormId" method="post" action="/private/userprofile/submit.action" modelAttribute="userProfileForm">
			<form:hidden path="id"/>
			<form:hidden path="enabled"/>
			<label id="loginFieldLabelId" for="loginFieldId" class="form-label registration-form-field-label">
				<fmt:message key="label.login"></fmt:message>:
			</label> 
			<form:input path="login" id="loginFieldId" cssClass="form-field"/>
    		<label id="passwordOldFieldLabelId" for="oldPasswordFieldId" class="form-label registration-form-field-label">
    			<fmt:message key="label.password.old"></fmt:message>:
    		</label> 
    		<form:password  path="oldPassword" id="oldPasswordFieldId" cssClass="form-field"/>
    		<label id="passwordFieldLabelId1" for="passwordFieldId1" class="form-label registration-form-field-label">
    			<fmt:message key="label.password.new"></fmt:message>:
    		</label> 
    		<form:password  path="password1" id="passwordFieldId1" cssClass="form-field"/>
    		<label id="passwordFieldLabelId2" for="passwordFieldId2" class="form-label registration-form-field-label">
    			<fmt:message key="label.password.repeat"></fmt:message>:
    		</label> 
    		<form:password path="password2" id="passwordFieldId2" cssClass="form-field"/>
    		<label id="firstNameFieldLabelId" for="firstNameFieldId" class="form-label registration-form-field-label">
    			<fmt:message key="label.firstname"></fmt:message>:
    		</label> 
			<form:input path="firstName" id="firstNameFieldId" cssClass="form-field"/>
			<label id="lastNameFieldLabelId" for="lastNameFieldId" class="form-label registration-form-field-label">
				<fmt:message key="label.lastname"></fmt:message>:
			</label> 
			<form:input path="lastName" id="lastNameFieldId" cssClass="form-field"/>
			<label id="emailFieldLabelId" for="emailFieldId" class="form-label registration-form-field-label">
				<fmt:message key="label.email"></fmt:message>:
			</label> 
			<form:input path="email" id="emailFieldId" cssClass="form-field"/>
    		<div class="registration-form-button-wrapper">
    			<a href="<%=request.getContextPath()+"/private/model/main.action"%>" class="form-button form-button-back-to-login">
    				<fmt:message key="button.back"></fmt:message>
    			</a>
    			<input type="button" id="clearButtonId" value="Очистить" class="form-button form-button-registration-clear" /> 
    			<input type="button" id="saveProfileButtonId" value="Сохранить" class="form-button form-button-register"/>
    		</div>
         </form:form>
	</div>
	<div class="form-footer">
	</div>
</div>

<div class="form-wrapper registration-form-error-wrapper">
	<div class="form-header">
		<div class="form-title form-error-title">
			<fmt:message key="label.error"></fmt:message>
		</div>
	</div>
	<ul id="errorsListId" class="form-error-text">
		<c:forEach var="err" items="${userProfileForm.errors}">
			<li>${err}</li>
		</c:forEach>
	</ul>		
	<div class="form-footer"></div>
</div>

<c:if test="${not empty userProfileForm.errors}">
	<script type="text/javascript">
		$('.registration-form-error-wrapper').css('display', 'inline-block');
	</script>
</c:if>

<script type="text/javascript">
	var messages = new Array();
	messages['message.error.field'] = '<fmt:message key="message.error.field"/>';
	messages['message.error.empty'] = '<fmt:message key="message.error.empty"/>';
	messages['message.error.field.length'] = '<fmt:message key="message.error.field.length"/>';
	messages['message.error.length.greater'] = '<fmt:message key="message.error.length.greater"/>';
	messages['message.error.passwords.not.equal'] = '<fmt:message key="message.error.passwords.not.equal"/>';
	messages['message.error.field.contain.incorrect.symbols'] = '<fmt:message key="message.error.field.contain.incorrect.symbols"/>';
	messages['message.error.field.invalid.format'] = '<fmt:message key="message.error.field.invalid.format"/>';
	messages['message.error.field.email.incorrect'] = '<fmt:message key="message.error.field.email.incorrect"/>';	
</script>

<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/app/userprofile.js"></script>
<%@include file="../public/footer.jsp" %>	